<?php
namespace app\shop\model;
use app\BaseModel;
use think\facade\Db;



class BargainAtvPv extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_shop_bargain_atv_pv';



    /**
     * @author chenniang
     * @DataTime: 2020-12-09 14:17
     * @功能说明:列表
     */
    public function dataList($dis,$page){

        $data = $this->where($dis)->order('top desc')->paginate($page)->toArray();

        return $data;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-12-09 14:18
     * @功能说明:添加
     */
    public function dataAdd($uniacid,$atv_id,$user_id){

        $dis = [

            'uniacid' => $uniacid,

            'atv_id'  => $atv_id,

            'user_id' => $user_id,
        ];

        $info = $this->dataInfo($dis);

        if(empty($info)){

            $this->insert($dis);

        }else{

            $this->where($dis)->update(['num'=>$info['num']+1]);
        }

        return true;

    }

    /**
     * @author chenniang
     * @DataTime: 2021-01-19 10:46
     * @功能说明:详情
     */
   public function dataInfo($dis){

       $data = $this->where($dis)->find();

       return !empty($data)?$data->toArray():[];


   }





}